Merged [13770]: Enabled saving ICQ aliases set in Adium to the server. Fixes #466
[adiumx.git] / Gaim Service / adiumGaimNotify.m
blob90811b91b1d086438c607bd719c9fcbab66147d0
1 /* 
2  * Adium is the legal property of its developers, whose names are listed in the copyright file included
3  * with this source distribution.
4  * 
5  * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6  * General Public License as published by the Free Software Foundation; either version 2 of the License,
7  * or (at your option) any later version.
8  * 
9  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
10  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
11  * Public License for more details.
12  * 
13  * You should have received a copy of the GNU General Public License along with this program; if not,
14  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
15  */
17 #import "ESGaimNotifyEmailController.h"
18 #import "adiumGaimNotify.h"
19 #import "SLGaimCocoaAdapter.h"
20 #import <AIUtilities/CBObjectAdditions.h>
22 static void *adiumGaimNotifyMessage(GaimNotifyMsgType type, const char *title, const char *primary, const char *secondary, GCallback cb,void *userData)
24         GaimDebug (@"adiumGaimNotifyMessage: type: %i\n%s\n%s\n%s ",
25                            type,
26                            (title ? title : ""),
27                            (primary ? primary : ""),
28                            (secondary ? secondary : ""));
30         return ([[SLGaimCocoaAdapter sharedInstance] handleNotifyMessageOfType:type
31                                                                                                                                  withTitle:title
32                                                                                                                                    primary:primary
33                                                                                                                                  secondary:secondary]);
36 static void *adiumGaimNotifyEmails(size_t count, gboolean detailed, const char **subjects, const char **froms, const char **tos, const char **urls, GCallback cb,void *userData)
38     //Values passed can be null
39     return([ESGaimNotifyEmailController handleNotifyEmails:count 
40                                                                                                   detailed:detailed
41                                                                                                   subjects:subjects
42                                                                                                          froms:froms
43                                                                                                            tos:tos
44                                                                                                           urls:urls]);
47 static void *adiumGaimNotifyEmail(const char *subject, const char *from, const char *to, const char *url, GCallback cb,void *userData)
49         return(adiumGaimNotifyEmails(1,
50                                                                  TRUE,
51                                                                  (subject ? &subject : NULL),
52                                                                  (from ? &from : NULL),
53                                                                  (to ? &to : NULL),
54                                                                  (url ? &url : NULL),
55                                                                  cb, userData));
58 static void *adiumGaimNotifyFormatted(const char *title, const char *primary, const char *secondary, const char *text, GCallback cb,void *userData)
60         GaimDebug (@"adiumGaimNotifyFormatted: %s\n%s\n%s\n%s ",
61                            (title ? title : ""),
62                            (primary ? primary : ""),
63                            (secondary ? secondary : ""),
64                            (text ? text : ""));
66         return ([[SLGaimCocoaAdapter sharedInstance] handleNotifyFormattedWithTitle:title
67                                                                                                                                                 primary:primary
68                                                                                                                                           secondary:secondary
69                                                                                                                                                    text:text]); 
72 static void *adiumGaimNotifyUserinfo(GaimConnection *gc, const char *who, const char *title, const char *primary, const char *secondary, const char *text, GCallback cb,void *userData)
74         NSString        *textString = [NSString stringWithUTF8String:text];
75         
76         if (GAIM_CONNECTION_IS_VALID(gc)){
77                 GaimAccount             *account = gc->account;
78                 GaimBuddy               *buddy = gaim_find_buddy(account,who);
79                 AIListContact   *theContact = contactLookupFromBuddy(buddy);
80                 
81                 
82                 [accountLookup(account) mainPerformSelector:@selector(updateUserInfo:withData:)
83                                                                                  withObject:theContact
84                                                                                  withObject:textString];
85         }
86         
87     return(adium_gaim_get_handle());
90 static void *adiumGaimNotifyUri(const char *uri)
92         if (uri){
93                 NSURL   *notifyURI = [NSURL URLWithString:[NSString stringWithUTF8String:uri]];
94                 [[NSWorkspace sharedWorkspace] openURL:notifyURI];
95         }
96         
97         return(adium_gaim_get_handle());
100 static void adiumGaimNotifyClose(GaimNotifyType type,void *uiHandle)
102         GaimDebug (@"adiumGaimNotifyClose");
105 static GaimNotifyUiOps adiumGaimNotifyOps = {
106     adiumGaimNotifyMessage,
107     adiumGaimNotifyEmail,
108     adiumGaimNotifyEmails,
109     adiumGaimNotifyFormatted,
110         adiumGaimNotifyUserinfo,
111     adiumGaimNotifyUri,
112     adiumGaimNotifyClose
115 GaimNotifyUiOps *adium_gaim_notify_get_ui_ops(void)
117         return &adiumGaimNotifyOps;